package com.mhc.suzuki.manager.impl;

import com.mhc.suzuki.dal.mapper.ext.CustomerExtMapper;
import com.mhc.suzuki.dal.model.CustomerDO;
import com.mhc.suzuki.dal.query.CustomerQuery;
import com.mhc.suzuki.manager.CustomerManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


/**
 * Manager for Customer.
 */

@Component
public class CustomerManagerImpl implements CustomerManager {


    @Autowired
    protected CustomerExtMapper customerExtMapper;

    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(CustomerQuery query) {
        return customerExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(CustomerQuery query) {
        return customerExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(CustomerDO record) {
        return customerExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(CustomerDO record) {
        return customerExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<CustomerDO> selectByQuery(CustomerQuery query) {
        return customerExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
     */
    @Override
    public PageResult<CustomerDO> selectByQueryWithPage(CustomerQuery query) {
        PageResult<CustomerDO> result = new PageResult<CustomerDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public CustomerDO selectByPrimaryKey(Long id) {
        return customerExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective(CustomerDO record, CustomerQuery query) {
        return customerExtMapper.updateByQuerySelective(record, query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery(CustomerDO record, CustomerQuery query) {

        return customerExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(CustomerDO record) {
        return customerExtMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public CustomerDO getExchangedBuyer(Map<String, Object> map) {
        return customerExtMapper.getExchangedBuyer(map);
    }

    @Override
    public CustomerDO getExchangedCommonBuyer(Map<String, Object> map) {
        return customerExtMapper.getExchangedCommonBuyer(map);
    }
}